<?php
//Apsauga
if (!defined("OK")) { header('location: ./?home'); }

// Projektu sarasas ir linkinimas i juos
$sql = mysql_query1("SELECT * FROM projektai");
while ($row = mysql_fetch_assoc($sql)) {	if ($_SESSION['username']) {		if (defined("LEVEL") && LEVEL == 30) {			$text .= "<img src=\"images/icons/bullet2.gif\" alt=\"o\" align=\"absmiddle\" border=\"0\"/> <a href='?id," . $row['id'] ."'>" . $row['pav'] ."</a><br/>";
		}		else {
			if ($row['rodyti'] == 'TAIP') {				$text .= "<img src=\"images/icons/bullet2.gif\" alt=\"o\" align=\"absmiddle\" border=\"0\"/> <a href='?id," . $row['id'] ."'>" . $row['pav'] ."</a><br/>";
			}
		}
	}
}
lentele("NightVision Extra", $text);

// Google PageRank
include "projektai/pagerank.php";

//Useriu TOPAS
$q = mysql_query1("SELECT id, nick, avatar, taskai FROM users WHERE `taskai` > 0 ORDER BY `taskai` DESC LIMIT 10");
unset($i);
while ($row = mysql_fetch_assoc($q)) {
	//?id,47;m,3
	$i++;
	if ($i == 1) { $img = "<img src=\"images/icons/rosette.png\" alt=\"o\" align=\"absmiddle\" border=\"0\"/>"; }
	elseif ($i == 2) { $img = "<img src=\"images/icons/medal_gold_2.png\" alt=\"o\" align=\"absmiddle\" border=\"0\"/>"; }
	elseif ($i == 3) { $img = "<img src=\"images/icons/medal_silver_2.png\" alt=\"o\" align=\"absmiddle\" border=\"0\"/>"; }
	elseif ($i == 4) { $img = "<img src=\"images/icons/medal_bronze_2.png\" alt=\"o\" align=\"absmiddle\" border=\"0\"/>"; }
	else { $img = "<img src=\"images/icons/bullet_star.png\" alt=\"o\" align=\"absmiddle\" border=\"0\">"; }	$text .= "<div class=\"sarasas\"><br/><b>".$i."</b> $img <a href='?id,47;m,".$row['id']."' class=\"th\">".$row['nick']."<span>
	".$row['nick']."<br /><img src=\"".$row['avatar']."\" /></span></a> (".$row['taskai'].")</div>\n";
}
lentele("TOP10",$text,"Lankytoju top"); unset($text,$i,$img);


//Kas naujo lentele
//$sql = mysql_fetch_assoc(mysql_query1("SELECT login_data FROM users WHERE id=".escape($_SESSION['id']).""));
if (isset($_SESSION['lankesi']) && $_SESSION['lankesi'] > 0) {
	$text = "".$_SESSION['lankesi']."<br />";
	
	//?id,25;t,7;s,26
	/*$forumas = mysql_query1("
	SELECT `d_zinute`.`tid`, `d_zinute`.`sid`, `d_straipsniai`.`pav` AS `tema`
	FROM `d_zinute`
	LEFT JOIN `d_straipsniai`
	ON `d_straipsniai`.`tid`=`d_zinute`.`tid`
	WHERE `d_zinute`.`laikas` >= ".escape($_SESSION['lankesi'])."
	GROUP BY tema
	ORDER BY `d_zinute`.`laikas` DESC
	LIMIT 10");*/
	$q = mysql_query1("SELECT `id`,`tid`,`pav` FROM `d_straipsniai` WHERE `d_straipsniai`.`last_data` >= ".escape($_SESSION['lankesi'])." ORDER BY `d_straipsniai`.`last_data` DESC LIMIT 0,5");
	$text .= "Forume:<br/>";
	while ($row = mysql_fetch_assoc($q)) {
		//http://85.232.143.6/nvs/?id,22;p,16;t,6		$text .= "\t <img src=\"images/icons/bullet2.gif\" alt=\"o\" align=\"absmiddle\" border=\"0\" /> <a href='?id,25;t,".$row['tid'].";s,".$row['id']."#end'>".$row['pav']."</a><br />\n";
	}
	
	
	$q = mysql_query1("SELECT id, pid, pav, t_text FROM straipsniai WHERE date>=".escape($_SESSION['lankesi'])." LIMIT 10");
	$text .= "<hr/>Straipsnių:<br/>";
	while ($row = mysql_fetch_assoc($q)) {
		//http://85.232.143.6/nvs/?id,22;p,16;t,6		$text .= "<img src=\"images/icons/bullet2.gif\" alt=\"o\" align=\"absmiddle\" border=\"0\" /> <a href='?id,22;p,".$row['pid'].";t,".$row['id']."'>".$row['pav']."</a><br />\n";
	}
	lentele("Kas naujo svetainėje",$text);
}
?>